package zuoye.zuoye4;

import java.util.HashSet;
import java.util.Random;

public class Test {
    public static void main(String[] args) {
        HashSet<Integer> hs = new HashSet<>();
        Random r = new Random();
        int i = 1;
        while (hs.size()<8) {
            int a = r.nextInt(10,21);
            System.out.println("第："+i+"次生成的数是："+a);
            hs.add(a);
            i++;
        }
        System.out.println(hs);
    }
}
